#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 400 + 7;
char s[maxn][maxn];
int a[maxn][maxn];
int ans[maxn];
int vis[maxn], one[maxn], sum[maxn];
int n, m;
int all = 0;
void dfs(int c)
{
    if (all)
        return;
    if (c == m)
    {
        all = 1;
        return;
    }
    for (int i = 1; i < m; ++i)
    {
        if (vis[i] == 0)
        {
            bool ok = 1;
            for (int j = 0; j < n; ++j)
            {
                if (a[j][i] == 1)
                {
                    if (one[j] && a[j][ans[c - 1]] == 0)
                    {
                        ok = 0;
                        break;
                    }
                }
                else
                {
                    if (one[j] && one[j] < sum[j])
                    {
                        ok = 0;
                        break;
                    }
                }
            }
            if (!ok)
                continue;
            vis[i] = 1;
            for (int j = 0; j < n; ++j)
            {
                one[j] += a[j][i];
            }
            if (!all)
                ans[c] = i;
            dfs(c + 1);
            vis[i] = 0;
            for (int j = 0; j < n; ++j)
            {
                one[j] -= a[j][i];
            }
        }
    }
}
int main()
{
    scanf("%d %d", &n, &m);
    memset(vis, 0, sizeof vis);
    vis[0] = 1;
    for (int i = 0; i < n; ++i)
    {
        scanf("%s", s[i]);
        if (s[i][0] == '1')
            one[i]++;
        for (int j = 0; s[i][j]; ++j)
        {
            if (s[i][j] == '1')
                a[i][j] = 1;
            else
                a[i][j] = 0;
            sum[i] += a[i][j];
        }
    }
    dfs(1);
    for (int i = 0; i < m; ++i)
        printf("%d\n", ans[i]);
    return 0;
}